<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <input type="text" name="" id="num">年
    <input type="text" name="" id="num1">月
    <button id="btn">显示当月的天数</button>
    <input type="text" name="" id="day">天


    <script>
        document.getElementById("btn").onclick = function() {
            var _num = Number(document.getElementById("num").value);
            var _num1 = Number(document.getElementById("num1").value);
            if (_num % 4 === 0 && _num % 100 != 0 || _num % 400 === 0) {
                switch (_num1) {
                    case _num1 = 1:
                    case _num1 = 3:
                    case _num1 = 5:
                    case _num1 = 7:
                    case _num1 = 8:
                    case _num1 = 10:
                    case _num1 = 12:
                        document.getElementById("day").value = "31天";
                        break;
                    case _num1 = 2:
                        document.getElementById("day").value = "29天";
                        break;
                    case _num1 = 4:
                    case _num1 = 6:
                    case _num1 = 9:
                    case _num1 = 11:
                        document.getElementById("day").value = "30天";
                        break;
                    default:
                        document.getElementById("day").value = "请正确输入";
                        break;
                }

            } else {
                switch (_num1) {
                    case _num1 = 1:
                    case _num1 = 3:
                    case _num1 = 5:
                    case _num1 = 7:
                    case _num1 = 8:
                    case _num1 = 10:
                    case _num1 = 12:
                        document.getElementById("day").value = "31天";
                        break;
                    case _num1 = 2:
                        document.getElementById("day").value = "28天";
                        break;

                    case _num1 = 4:
                    case _num1 = 6:
                    case _num1 = 9:
                    case _num1 = 11:
                        document.getElementById("day").value = "30天";
                        break;
                    default:
                        document.getElementById("day").value = "请正确输入";
                        break;
                }
            }
        }
    </script>
</body>

</html>